//
//  UITableView+Extensions.swift
//  JT-Architecture
//
//  Created by 果咱 on 2020/12/15.
//

import Foundation
import UIKit

extension NSObject {
    static var className: String { return "\(self)"}
    var className: String { return "\(classForCoder)" }
}

extension UITableViewCell {
    static var identifier: String { return className }
}

extension UICollectionViewCell {
    static var identifier: String { return className }
}

extension UITableView {
    
    func registerNibClass<T: UITableViewCell>(_ type: T.Type) {
        register(UINib(nibName: type.className, bundle: nil), forCellReuseIdentifier: type.className)
    }
    
    func registerNormalClass<T: UITableViewCell>(_ type: T.Type) {
        register(type, forCellReuseIdentifier: type.className)
    }
}

extension UICollectionView {
    
    func registerNibClass<T: UICollectionViewCell>(_ type: T.Type) {
        register(UINib(nibName: type.className, bundle: nil), forCellWithReuseIdentifier: type.className)
    }
    
    func registerNormalClass<T: UICollectionViewCell>(_ type: T.Type) {
        register(type, forCellWithReuseIdentifier: type.className)
    }
}

extension IndexPath {
    static var zero: IndexPath { return IndexPath(row: 0, section: 0) }
}
